package org.dyndns.opendemogroup.optimizer.problems;

import static org.junit.Assert.*;

import org.dyndns.opendemogroup.optimizer.Member;
import org.junit.Test;

/**
 * A class to test the class Rastrigin
 */
public class RastriginTest
{

	/**
	 * Tests the <i>computeFitness</i> method with the optimal case, according
	 * to the assignment's definition of the problem.
	 */
	@Test
	public void computeFitness_AssignmentDefinition ( )
	{
		// { set-up
		int memberSize = 30;
		int a = 10;
		Rastrigin rastrigin = new Rastrigin ( memberSize, a );

		Member source = new Member ( rastrigin.getMemberSize ( ) );
		for ( int i = 0; i < memberSize; i++ )
		{
			source.genome[i] = 0.0;
		}
		rastrigin.decodeFrom ( source );
		// }

		double actual = rastrigin.computeFitness ( null );
		double expected = 0.0;
		assertEquals ( expected, actual );
	}

}
